# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  include TagsHelper
  def logged_in?
    return @session[:user_id] ? true : false
  end
  
  def paginate_number(number, current, order = nil)
    i = 0
    result = ""
    return '<span class="current">1</span>' if number.to_i == 1
    number.to_i.times {|i|
      if i+1==current
        result.concat("<span>#{i+1}</span>")
      else
        result.concat(link_to(i+1,{:page => i+1, 'order' => order},:class => 'current'))
      end
    }
    logger.debug("Result::"+result)
    result
  end
end

module ActionView
  module Helpers
    module PaginationHelper
      def pagination_links_remote(paginator, page_options={}, ajax_options={}, html_options={})
        name = page_options[:name] || DEFAULT_OPTIONS[:name]
        params = (page_options[:params] || DEFAULT_OPTIONS[:params]).clone
        params[:search_type] = ajax_options[:search_type]
        params[:keyword]     = ajax_options[:keyword]
        pagination_links_each(paginator, page_options) do |n|
          params[name] = n
          ajax_options[:url] = params
          link_to_remote(n.to_s, ajax_options, html_options)
        end
      end
    end # PaginationHelper
  end # Helpers
end # ActionView
